<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
$TemUrl = "../templates/";
if(empty($_GET['dir'])) MsgBox(1,'参数有误！','-1');
$TemUrl .= $_GET['dir'] . "/";
if(!is_dir($TemUrl)) MsgBox(1,"目录不存在:{$TemUrl}",'-1');
$File = $_GET['File'];
if(!is_file($TemUrl.$File)) $File = "index{$TemplateSuffix}";
@include_once("{$TemUrl}info.ini");

$APFile = $TemUrl.$File;
if(!empty($_POST['TemConfig'])){
	if(!@$fp = fopen($APFile,'w')) MsgBox(1,"没有写入 $APFile 的权限！","1"); //写入
	$fw = fwrite($fp,stripcslashes(trim($_POST['TemConfig'])));
	fclose($fp);

	include_once('../tools/smarty/Smarty.class.php');
	$SC = new SC();
	$SC -> cache_dir  = '../tmp/cache';
	$SC -> compile_dir = "../tmp/translation";
	$SC -> cache -> clearAll(); 
	$SC -> utility -> clearCompiledTemplate();

	AdminLog(1,1,'修改模板[' . $_GET['dir'] . ']，结果：操作成功！');
	MsgBox (1,'数据修改成功！','1');	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd">
		<td>&nbsp;</td>
		<td align="right" height="25"><input type="button" value="模板管理" onClick="javascript:location.href='TemplateManage.php';">&nbsp;</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
<form id="form1" name="form1" method="post" action="">
  <tr>
    <td colspan="2" align="center" class="Main_Title">模板编辑 [<?php echo $TemName;?>]</td>
  </tr>
  <tr class="odd">
    <td width="200" height="20" align="center" class="b">文件列表</td>
    <td align="center" class="b">源代码 [<?php echo $File;?>]</td>
  </tr>
  <tr>
    <td width="200" align="left" style="line-height:20px; background:#FFF;" valign="top">
<?php
$FileArr = MyScandir($TemUrl);
foreach ($FileArr as $i => &$n){
	$n = iconv("GB2312","UTF-8",$n);
	$no = NULL;
	if(('.'.Extend($n) == $TemplateSuffix || Extend($n)=='css' || Extend($n)=='php' || $n=='info.ini')){
		if(Extend($n)=='css') $no = '[<font color="#6600CC">样式表</font>]';
		if($n=='info.ini') $no = '[<font color="#6600CC">模板配置信息</font>]';
//		if($n=='navigation.php') $no = '[<font color="#FF0000">语言包</font>]';
		echo "<a href=\"TemplateUpDate.php?dir={$_GET['dir']}&File={$n}\">$n</a> {$no}<br /> \n";
		
	}
}
?>	
	</td>
    <td align="center" style="background:#FFF;">
<textarea name="TemConfig" wrap="off" style="width:96%; height:500px; border:1px #999 solid; color:#093; padding:5px; font-family:'新宋体', '宋体';"><?php
@$handle = fopen($APFile, "r");
@$contents = fread($handle,filesize($APFile));
echo htmlspecialchars($contents);
@fclose($handle); 
?></textarea><br /><br />
<input type="submit" name="button" id="button" value="修 改" class="submit" /><br /><br /></td>
  </tr>
  </form>
  </table>
  
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">&nbsp;</td>
	</tr>
</table>  
</body>
</html>
